import { FileListType } from '@renderer/types/global'
import axios from 'axios'

// 模块：工资表
const modelUrl = '/finance'
// 工资表-列表
export interface SalarySheetReq {
  payrollMonth: string
}
export interface SalarySheetRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: SalarySheetResItem[]
}
export interface SalarySheetResItem {
  payrollId: string
  payrollMonth: string
  numberOfEmployee: number
  givedCount: number
  ungiveCount: number
}
export interface SalarySheetSearch {
  payrollStartMonth?: string
  payrollEndMonth?: string
  payrollMonth: string[]
}
export function editSalarySheetList(data: SalarySheetReq) {
  return axios.post<SalarySheetRes>(modelUrl + '/payrollAdit', data)
}

export function delSalarySheetList(data: { payrollId: string }) {
  return axios.post<object>(modelUrl + '/payrollDel', data)
}

export function getSalarySheetListDetail(data: { payrollId: string }) {
  return axios.post<SalarySheetRes>(modelUrl + '/payrollDetail', data)
}

export function getSalarySheetListAllList(data?: SalarySheetSearch) {
  return axios.post<SalarySheetRes>(modelUrl + '/payrollList', data)
}

export function getSalarySheetListPageList(data: SalarySheetSearch) {
  return axios.post<SalarySheetRes>(modelUrl + '/payrollPage', data)
}

// 工资表-详情
export interface SalarySheetDetailReq {
  payrollMemberId?: string
  payrollId?: string
  employeeId?: string
  baseSalaryAmt: number
  saleCommissionAmt: number
  pieceCommissionAmt: number
  deliveryOmmissionAmt: number
  otherAmt: number
  overtimeAmt: number
  attendanceAmt: number
  expendAmt: number
  totalAmt: number
  status: number
  remark: string
  fileList: FileListType[]
}
export interface SalarySheetDetailRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: SalarySheetDetailResItem[]
}
export interface SalarySheetDetailResItem {
  payrollMemberId: string
  payrollId: string
  employeeId: string
  baseSalaryAmt: number
  saleCommissionAmt: number
  pieceCommissionAmt: number
  deliveryOmmissionAmt: number
  otherAmt: number
  overtimeAmt: number
  attendanceAmt: number
  expendAmt: number
  totalAmt: number
  status: number
  remark: string
  employeeName: string
  fileList: FileListType[]
}
export interface SalarySheetDetailSearch {
  payrollId: string
  employeeName: string
  status: string
}
export function editSalarySheetDetail(data: SalarySheetDetailReq) {
  return axios.post<SalarySheetDetailRes>(modelUrl + '/payrollMemberAdit', data)
}

export function delSalarySheetDetail(data: { payrollMemberId: string }) {
  return axios.post<object>(modelUrl + '/payrollMemberDel', data)
}

export function getSalarySheetDetail(data: { payrollMemberId: string }) {
  return axios.post<SalarySheetDetailResItem>(modelUrl + '/payrollMemberDetail', data)
}

export function getSalarySheetDetailAllList(data: SalarySheetDetailSearch) {
  return axios.post<SalarySheetDetailRes>(modelUrl + '/payrollMemberList', data)
}

export function getSalarySheetDetailPageList(data: SalarySheetDetailSearch) {
  return axios.post<SalarySheetDetailRes>(modelUrl + '/payrollMemberPage', data)
}

export function payrollMemberBatchGive(data: { payrollId: string; idList: string[] }) {
  return axios.post<SalarySheetDetailRes>(modelUrl + '/payrollMemberBatchGive', data)
}
